/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principal.java
 *
 * Created on 13-dic-2011, 18:59:41
 */

package practica1_ayd2;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Gracu
 */
public class Principal extends javax.swing.JFrame {
/***************************************************************************
 *********************DECLARACIONES**********************************
 **************************************************************************/
    Busquedas busq=new Busquedas();
    Listas listas=new Listas();
    DefaultTableModel dtm2= new DefaultTableModel();
    DefaultTableModel dtm1= new DefaultTableModel();
    DefaultTableModel dtm_con_peli= new DefaultTableModel();
    DefaultTableModel dtm_con_renta= new DefaultTableModel();
    DefaultTableModel dtm_con_cliente= new DefaultTableModel();
    

    /** Creates new form Principal */

    public Principal() {
        initComponents();
        inicializar();




    }
    public void inicializar(){
        this.dia_mes_anio();
        dtm2=(DefaultTableModel)this.jTable1.getModel();
        this.jTable1.setModel(dtm2);

        dtm1=(DefaultTableModel)this.JT_tablaclientes.getModel();
        this.JT_tablaclientes.setModel(dtm1);

        dtm_con_peli=(DefaultTableModel)this.JT_consulta_pelicula.getModel();
        this.JT_consulta_pelicula.setModel(dtm_con_peli);

        dtm_con_renta=(DefaultTableModel)this.JT_consulta_renta.getModel();
        this.JT_consulta_renta.setModel(dtm_con_renta);

        dtm_con_cliente=(DefaultTableModel)this.JT_consultacliente.getModel();
        this.JT_consultacliente.setModel(dtm_con_cliente);

        this.JC_peliedad.add("12");
        this.JC_peliedad.add("15");
        this.JC_peliedad.add("18");
        this.JC_peliedad.add("25");

    }


/***************************************************************************
 *********************CARGAR DATOS EN LOS COMBOBOX*************************
 **************************************************************************/
  public void load_pelicula(){
        this.JC_idpelicula.removeAll();
        for(int i=0;i<listas.get_peliculas().size();i++){
            this.JC_idpelicula.add(String.valueOf(listas.get_peliculas().get(i).get_id_pelicula()));
        }
    }
   public void load_estudio(){
        this.JC_estudio.removeAll();
        for(int i=0;i<listas.get_estudio().size();i++){
            this.JC_estudio.add(listas.get_estudio().get(i).get_estudio());
        }
    }

    public void load_genero(){
        this.JC_genero.removeAll();
        for(int i=0;i<listas.get_genero().size();i++){
            this.JC_genero.add(listas.get_genero().get(i).get_genero());
        }
    }
    public void dia_mes_anio(){
        this.JC_rentadia.removeAll();
        this.JC_rentames.removeAll();
        this.JC_rentaanio.removeAll();
        for(int i=1;i<=31;i++){
            this.JC_rentadia.add(String.valueOf(i));
        }
        for(int i=1;i<=12;i++){
            this.JC_rentames.add(String.valueOf(i));
        }
        for(int i=2009;i<2012;i++){
            this.JC_rentaanio.add(String.valueOf(i));
        }
    }
/**************COMPARAR FECHAS*************************/
    public String get_retraso(int day, int month,int year){
            Calendar calendar = Calendar.getInstance();
            int dia = calendar.get(Calendar.DAY_OF_MONTH);   //dia del mes
            int mes = calendar.get(Calendar.MONTH);  //mes, de 0 a 11
            int anio = calendar.get(Calendar.YEAR);  //año
            Date d1=calendar.getTime();
            Date d2=new Date();
            d2.setYear(year);
            d2.setDate(day);
            d2.setMonth(month-1);

            d1.setYear(anio);
            d1.setDate(dia);
            d1.setMonth(mes);

            //System.out.println(dia+"/"+mes+"/"+anio+"--"+d1.getDate());
            //System.out.println(d2.getDate()+"/"+d2.getMonth()+"/"+d2.getYear());
            //System.out.println(d1.getDate()+"/"+d1.getMonth()+"/"+d1.getYear());

            long dif = d1.getTime() - d2.getTime();
            // 3600 * 24 * 1000=86400000L
            //renta de 5 dias despues de 5 dias ya esta retrasado
            long dias_restantes =(dif / 86400000L)-5L;
            String dias="0";
            if(dias_restantes>0L)
                dias=String.valueOf(dias_restantes);
             return dias;
    }
 /***************************************************************************
 *********************LLENAR TABLA DE RENTA**********************************
 **************************************************************************/
    public void set_tabla_cons_cliente(String search,DefaultTableModel dtm){
        
        if(search.length()>0 && this.isNumeric(search)){
            ArrayList<Rentas> newrentas=this.busq.search_renta_array(listas.get_rentas(), Integer.parseInt(search));
            String matriz[][]=new String[newrentas.size()][4];
            for(int i=0;i<newrentas.size();i++){
                
                String [] val={String.valueOf(newrentas.get(i).get_id_renta()),String.valueOf(newrentas.get(i).get_id_pelicula()),
                   String.valueOf(newrentas.get(i).get_id_cliente()),
                   String.valueOf(newrentas.get(i).get_dia())+"/"+String.valueOf(newrentas.get(i).get_mes())+"/"+String.valueOf(newrentas.get(i).get_anio()),
                    get_retraso(newrentas.get(i).get_dia(),newrentas.get(i).get_mes(),newrentas.get(i).get_anio())};
                matriz[i]=val;
            }

            dtm.setRowCount(0);
            for(int i=0;i<newrentas.size();i++){
                dtm.addRow(matriz[i]);
            }
        }
    }
    public void set_tabla(String search,DefaultTableModel dtm){
        if(search.length()>0 && this.isNumeric(search)){
            ArrayList<Rentas> newrentas=this.busq.search_renta_array(listas.get_rentas(), Integer.parseInt(search));
            String matriz[][]=new String[newrentas.size()][4];
            for(int i=0;i<newrentas.size();i++){
                String [] val={String.valueOf(newrentas.get(i).get_id_renta()),String.valueOf(newrentas.get(i).get_id_pelicula()),
                   String.valueOf(newrentas.get(i).get_id_cliente()),
                   String.valueOf(newrentas.get(i).get_dia())+"/"+String.valueOf(newrentas.get(i).get_mes())+"/"+String.valueOf(newrentas.get(i).get_anio())};
                matriz[i]=val;
            }

            dtm.setRowCount(0);
            for(int i=0;i<newrentas.size();i++){
                dtm.addRow(matriz[i]);
            }
        }
    }

    public void set_tabla_cliente(){

            String matriz[][]=new String[listas.get_clientes().size()][4];
            for(int i=0;i<listas.get_clientes().size();i++){
                String [] val={String.valueOf(listas.get_clientes().get(i).get_id_cliente()),listas.get_clientes().get(i).get_nombre(),listas.get_clientes().get(i).get_apellido(),
                        listas.get_clientes().get(i).get_direccion(),String.valueOf(listas.get_clientes().get(i).get_edad())};
                matriz[i]=val;
            }
            dtm1.setRowCount(0);
            for(int i=0;i<listas.get_clientes().size();i++){
                dtm1.addRow(matriz[i]);
            }
    }

        public void set_consulta_peli(){
        
            String matriz[][]=new String[this.listas.get_peliculas().size()][5];
            for(int i=0;i<listas.get_peliculas().size();i++){
                String [] val={String.valueOf(listas.get_peliculas().get(i).get_id_pelicula()),
                listas.get_peliculas().get(i).nombre,
                String.valueOf(listas.get_peliculas().get(i).get_edad()),
                listas.get_peliculas().get(i).get_genero(),
                listas.get_peliculas().get(i).get_estudio()};
                matriz[i]=val;
            }

            dtm_con_peli.setRowCount(0);
            for(int i=0;i<listas.get_peliculas().size();i++){
                dtm_con_peli.addRow(matriz[i]);
            }
        
    }

    public void set_consulta_renta(){
            String matriz[][]=new String[listas.get_rentas().size()][5];
            for(int i=0;i<listas.get_rentas().size();i++){
                String [] val={String.valueOf(listas.get_rentas().get(i).get_id_renta()),String.valueOf(listas.get_rentas().get(i).get_id_pelicula()),
                   String.valueOf(listas.get_rentas().get(i).get_id_cliente()),
                   String.valueOf(listas.get_rentas().get(i).get_dia())+"/"+String.valueOf(listas.get_rentas().get(i).get_mes())+"/"+String.valueOf(listas.get_rentas().get(i).get_anio()),
                    get_retraso(listas.get_rentas().get(i).get_dia(),listas.get_rentas().get(i).get_mes(),listas.get_rentas().get(i).get_anio())};
                matriz[i]=val;
            }

            dtm_con_renta.setRowCount(0);
            for(int i=0;i<listas.get_rentas().size();i++){
                dtm_con_renta.addRow(matriz[i]);
            }
    }
/***************************************************************************
 *********************DEVOLVER RENTA ***************************************
 **************************************************************************/
   public void devolver_renta(String id_cliente, String id_renta){
    if(id_cliente.length()>0 && id_renta.length()>0)
        if(listas.isNumeric(id_cliente) && listas.isNumeric(id_renta)){
            if(busq.search_renta_cliente_id(listas.get_rentas(),Integer.parseInt(id_renta),Integer.parseInt(id_cliente)))
                listas.set_rentas(busq.quit_renta_array(listas.get_rentas(), Integer.parseInt(id_cliente), Integer.parseInt(id_renta)));
           else
               JOptionPane.showMessageDialog(this,"El id de la renta asociado a este cliente no existe \n "
                       + "verifique que exista el cliente y la renta.");
        }
        else
           JOptionPane.showMessageDialog(this,"Debe ingresar solamente valores numericos");
     else
           JOptionPane.showMessageDialog(this,"Complete todos los campos por favor");
   }


/***************************************************************************
 *********************VERIFICAR SI ES NUMERICO******************************
 **************************************************************************/
    public  boolean isNumeric(String cadena){
            try {
                    Integer.parseInt(cadena);
                    return true;
            } catch (NumberFormatException nfe){
                    return false;
            }
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        JT_clienteidcliente = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        JT_clientename = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        JT_clienteapellido = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        JT_clientedir = new javax.swing.JTextField();
        JB_clienteaceptar = new javax.swing.JButton();
        JB_clientecancelar = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        JT_cliente_edad = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        JT_tablaclientes = new javax.swing.JTable();
        jLabel18 = new javax.swing.JLabel();
        JT_clienteclave = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        JT_peliculaidpelicula = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        JT_peliculanombre = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        JB_agregarpelicula = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        JC_genero = new java.awt.Choice();
        JC_estudio = new java.awt.Choice();
        jLabel17 = new javax.swing.JLabel();
        JC_peliedad = new java.awt.Choice();
        jPanel7 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        JT_estudio = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        JB_addestudio = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        JT_Genero = new javax.swing.JTextField();
        JB_addgenero = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        JB_addrenta = new javax.swing.JButton();
        JT_rentaid = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        JT_rentanombre = new javax.swing.JTextField();
        JC_idpelicula = new java.awt.Choice();
        label1 = new java.awt.Label();
        label2 = new java.awt.Label();
        JC_rentadia = new java.awt.Choice();
        JC_rentames = new java.awt.Choice();
        JC_rentaanio = new java.awt.Choice();
        jLabel16 = new javax.swing.JLabel();
        JT_rentaidcliente = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        JT_rentoclave = new javax.swing.JTextField();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel9 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jScrollPane5 = new javax.swing.JScrollPane();
        JT_consulta_pelicula = new javax.swing.JTable();
        jPanel11 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        JT_consulta_renta = new javax.swing.JTable();
        jPanel12 = new javax.swing.JPanel();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        JT_consultacliente = new javax.swing.JTable();
        jLabel20 = new javax.swing.JLabel();
        JT_consulta_cliente = new javax.swing.JTextField();
        JB_consultar_cliente = new javax.swing.JButton();
        jPanel14 = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        JT_setidcliente = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        JT_setidrenta = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTabbedPane1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTabbedPane1FocusGained(evt);
            }
        });

        jPanel2.setLayout(null);

        jLabel1.setText("id_cliente");
        jPanel2.add(jLabel1);
        jLabel1.setBounds(50, 10, 70, 14);
        jPanel2.add(JT_clienteidcliente);
        JT_clienteidcliente.setBounds(140, 10, 67, 20);

        jLabel2.setText("Nombre");
        jPanel2.add(jLabel2);
        jLabel2.setBounds(50, 40, 60, 14);
        jPanel2.add(JT_clientename);
        JT_clientename.setBounds(140, 40, 260, 20);

        jLabel3.setText("Apellido");
        jPanel2.add(jLabel3);
        jLabel3.setBounds(50, 80, 60, 14);
        jPanel2.add(JT_clienteapellido);
        JT_clienteapellido.setBounds(140, 80, 260, 20);

        jLabel4.setText("Direccion");
        jPanel2.add(jLabel4);
        jLabel4.setBounds(50, 110, 60, 14);
        jPanel2.add(JT_clientedir);
        JT_clientedir.setBounds(140, 120, 260, 20);

        JB_clienteaceptar.setText("Aceptar");
        JB_clienteaceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_clienteaceptarActionPerformed(evt);
            }
        });
        jPanel2.add(JB_clienteaceptar);
        JB_clienteaceptar.setBounds(100, 190, 90, 23);

        JB_clientecancelar.setText("Cancelar");
        jPanel2.add(JB_clientecancelar);
        JB_clientecancelar.setBounds(230, 190, 100, 23);

        jLabel5.setText("Edad");
        jPanel2.add(jLabel5);
        jLabel5.setBounds(250, 10, 40, 14);
        jPanel2.add(JT_cliente_edad);
        JT_cliente_edad.setBounds(340, 10, 50, 20);

        JT_tablaclientes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "id_cliente", "Nombre", "Apellido", "Direccion", "Edad"
            }
        ));
        jScrollPane2.setViewportView(JT_tablaclientes);

        jPanel2.add(jScrollPane2);
        jScrollPane2.setBounds(30, 240, 410, 110);

        jLabel18.setText("clave");
        jPanel2.add(jLabel18);
        jLabel18.setBounds(50, 160, 70, 14);

        JT_clienteclave.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        jPanel2.add(JT_clienteclave);
        JT_clienteclave.setBounds(140, 160, 120, 20);

        jTabbedPane1.addTab("Crear_cliente", jPanel2);

        jPanel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel10.setText("Id_pelicula");

        jLabel11.setText("Nombre");

        jLabel12.setText("Genero");

        jLabel13.setText("Estudio");

        JB_agregarpelicula.setText("Agregar");
        JB_agregarpelicula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_agregarpeliculaActionPerformed(evt);
            }
        });

        jButton2.setText("Cancelar");

        JC_genero.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                JC_generoFocusGained(evt);
            }
        });

        JC_estudio.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                JC_estudioFocusGained(evt);
            }
        });

        jLabel17.setText("Para Mayores de");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addGap(35, 35, 35)
                        .addComponent(JT_peliculaidpelicula, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(35, 35, 35)
                        .addComponent(jLabel17)
                        .addGap(19, 19, 19)
                        .addComponent(JC_peliedad, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(JT_peliculanombre, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(JC_genero, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(JB_agregarpelicula))
                                .addGap(58, 58, 58)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton2)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel13)
                                        .addGap(29, 29, 29)
                                        .addComponent(JC_estudio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))))
                .addContainerGap(146, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel10)
                        .addComponent(JT_peliculaidpelicula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel17))
                    .addComponent(JC_peliedad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(JT_peliculanombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel12)
                    .addComponent(JC_genero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(JC_estudio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(35, 35, 35)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(JB_agregarpelicula))
                .addContainerGap())
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel8.setText("Agregar Estudio");

        jLabel9.setText("Estudio");

        JB_addestudio.setText("ADD");
        JB_addestudio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_addestudioActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel8))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(JB_addestudio)
                            .addComponent(JT_estudio, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(145, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel8)
                .addGap(18, 18, 18)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(JT_estudio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addComponent(JB_addestudio)
                .addContainerGap(35, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel6.setText("Agregar Genero");

        jLabel7.setText("Genero");

        JB_addgenero.setText("ADD");
        JB_addgenero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_addgeneroActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel6))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(JT_Genero, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(103, 103, 103)
                        .addComponent(JB_addgenero)))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addGap(18, 18, 18)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(JT_Genero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addComponent(JB_addgenero)
                .addContainerGap(35, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Ingresar_pelicula", jPanel3);

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel14.setText("id_renta");

        JB_addrenta.setText("add_renta");
        JB_addrenta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_addrentaActionPerformed(evt);
            }
        });

        jLabel15.setText("nombre");

        JT_rentanombre.setEnabled(false);

        JC_idpelicula.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                JC_idpeliculaItemStateChanged(evt);
            }
        });
        JC_idpelicula.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                JC_idpeliculaFocusGained(evt);
            }
        });

        label1.setText("id_pelicula");

        label2.setText("Fecha dd/mm/yyyy");

        jLabel16.setText("id_cliente");

        jLabel19.setText("Clave_cliente");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(JC_idpelicula, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addGap(30, 30, 30)
                                .addComponent(JT_rentaid, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(123, 123, 123)
                        .addComponent(JB_addrenta))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(JC_rentadia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(JC_rentames, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(JC_rentaanio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 64, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel19)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel16)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(JT_rentaidcliente, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel15)
                                        .addGap(18, 18, 18)
                                        .addComponent(JT_rentanombre, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(50, 50, 50))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(75, 75, 75)
                        .addComponent(JT_rentoclave, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(JT_rentaid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(25, 25, 25)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JC_idpelicula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(JT_rentaidcliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(25, 25, 25)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(JT_rentanombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(31, 31, 31)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19)
                    .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(JC_rentames, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JC_rentaanio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(31, 31, 31)
                        .addComponent(JB_addrenta))
                    .addComponent(JC_rentadia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JT_rentoclave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "id_renta", "id_cliente", "id_pelicula", "fecha"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(67, 67, 67))
        );

        jTabbedPane1.addTab("Rentar", jPanel5);

        jPanel10.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        JT_consulta_pelicula.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "id_pelicula", "nombre", "mayores_de", "genero", "estudio"
            }
        ));
        jScrollPane5.setViewportView(JT_consulta_pelicula);

        jScrollPane3.setViewportView(jScrollPane5);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(29, Short.MAX_VALUE))
        );

        jPanel11.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        JT_consulta_renta.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "id_renta", "id_cliente", "id_pelicula", "fecha", "Retraso(dias)"
            }
        ));
        jScrollPane4.setViewportView(JT_consulta_renta);

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(35, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Consultas", jPanel9);

        jPanel13.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        JT_consultacliente.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "id_renta", "id_cliente", "id_pelicula", "fecha", "Retraso(dias)"
            }
        ));
        jScrollPane6.setViewportView(JT_consultacliente);

        jLabel20.setText("id_cliente");

        JB_consultar_cliente.setText("Consultar_cliente");
        JB_consultar_cliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_consultar_clienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel20)
                        .addGap(42, 42, 42)
                        .addComponent(JT_consulta_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(50, 50, 50)
                        .addComponent(JB_consultar_cliente))
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(JT_consulta_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JB_consultar_cliente))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel14.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel21.setText("id_cliente");

        jLabel22.setText("id_renta");

        jButton1.setText("Devolver_pelicula");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel21)
                .addGap(47, 47, 47)
                .addComponent(JT_setidcliente, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton1)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(jLabel22)
                        .addGap(18, 18, 18)
                        .addComponent(JT_setidrenta, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(210, Short.MAX_VALUE))
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(JT_setidcliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22)
                    .addComponent(JT_setidrenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(27, 27, 27))
        );

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jTabbedPane1.addTab("Cliente", jPanel12);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.getAccessibleContext().setAccessibleName("tab3");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void JB_addgeneroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_addgeneroActionPerformed
        listas.add_genero(this,this.JT_Genero.getText());
        load_genero();
        
    }//GEN-LAST:event_JB_addgeneroActionPerformed

    private void JC_generoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JC_generoFocusGained
       
        load_genero();
        // TODO add your handling code here:
    }//GEN-LAST:event_JC_generoFocusGained

    private void JC_estudioFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JC_estudioFocusGained
         load_estudio();
         
        // TODO add your handling code here:
    }//GEN-LAST:event_JC_estudioFocusGained

    private void JB_addestudioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_addestudioActionPerformed
        listas.add_estudio(this,this.JT_estudio.getText());
        load_estudio();
        // TODO add your handling code here:
    }//GEN-LAST:event_JB_addestudioActionPerformed

    private void JB_clienteaceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_clienteaceptarActionPerformed
        listas.add_cliente(this,this.JT_clienteidcliente.getText(),
                this.JT_clientename.getText(),
                this.JT_clienteapellido.getText(),
                this.JT_clientedir.getText(),
                this.JT_cliente_edad.getText(),
                this.JT_clienteclave.getText());
        set_tabla_cliente();
    }//GEN-LAST:event_JB_clienteaceptarActionPerformed

    private void JB_agregarpeliculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_agregarpeliculaActionPerformed
       listas.add_pelicula(this,this.JC_genero.getSelectedItem(),this.JC_estudio.getSelectedItem(),
               this.JT_peliculanombre.getText(),this.JT_peliculaidpelicula.getText(),this.JC_peliedad.getSelectedItem());
        load_pelicula();
    }//GEN-LAST:event_JB_agregarpeliculaActionPerformed

    private void JB_addrentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_addrentaActionPerformed

        //(String id_renta,String id_cliente,String id_pelicula, String dia, String mes,String anio){
        listas.add_renta(this,this.JT_rentoclave.getText(),this.JT_rentaid.getText(),
                        this.JT_rentaidcliente.getText(),
                        this.JC_idpelicula.getSelectedItem(),
                        this.JC_rentadia.getSelectedItem(),
                        this.JC_rentames.getSelectedItem(),
                        this.JC_rentaanio.getSelectedItem());
        set_tabla(this.JT_rentaidcliente.getText(),this.dtm2);
        // TODO add your handling code here:
    }//GEN-LAST:event_JB_addrentaActionPerformed

    private void JC_idpeliculaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JC_idpeliculaFocusGained
        load_pelicula();        // TODO add your handling code here:
    }//GEN-LAST:event_JC_idpeliculaFocusGained

    private void JC_idpeliculaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_JC_idpeliculaItemStateChanged


        this.JT_rentanombre.setText(busq.search_peliculas_getnombre(listas.get_peliculas(),Integer.parseInt(this.JC_idpelicula.getSelectedItem())));
        // TODO add your handling code here:
    }//GEN-LAST:event_JC_idpeliculaItemStateChanged

    private void jTabbedPane1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTabbedPane1FocusGained
        set_consulta_peli();
        this.set_consulta_renta();
         // TODO add your handling code here:
    }//GEN-LAST:event_jTabbedPane1FocusGained

    private void JB_consultar_clienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_consultar_clienteActionPerformed
        set_tabla_cons_cliente(this.JT_consulta_cliente.getText(),this.dtm_con_cliente);
    }//GEN-LAST:event_JB_consultar_clienteActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        devolver_renta(this.JT_setidcliente.getText(),this.JT_setidrenta.getText());
        set_tabla_cons_cliente(this.JT_setidcliente.getText(),this.dtm_con_cliente);
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JB_addestudio;
    private javax.swing.JButton JB_addgenero;
    private javax.swing.JButton JB_addrenta;
    private javax.swing.JButton JB_agregarpelicula;
    private javax.swing.JButton JB_clienteaceptar;
    private javax.swing.JButton JB_clientecancelar;
    private javax.swing.JButton JB_consultar_cliente;
    private java.awt.Choice JC_estudio;
    private java.awt.Choice JC_genero;
    private java.awt.Choice JC_idpelicula;
    private java.awt.Choice JC_peliedad;
    private java.awt.Choice JC_rentaanio;
    private java.awt.Choice JC_rentadia;
    private java.awt.Choice JC_rentames;
    private javax.swing.JTextField JT_Genero;
    private javax.swing.JTextField JT_cliente_edad;
    private javax.swing.JTextField JT_clienteapellido;
    private javax.swing.JTextField JT_clienteclave;
    private javax.swing.JTextField JT_clientedir;
    private javax.swing.JTextField JT_clienteidcliente;
    private javax.swing.JTextField JT_clientename;
    private javax.swing.JTextField JT_consulta_cliente;
    private javax.swing.JTable JT_consulta_pelicula;
    private javax.swing.JTable JT_consulta_renta;
    private javax.swing.JTable JT_consultacliente;
    private javax.swing.JTextField JT_estudio;
    private javax.swing.JTextField JT_peliculaidpelicula;
    private javax.swing.JTextField JT_peliculanombre;
    private javax.swing.JTextField JT_rentaid;
    private javax.swing.JTextField JT_rentaidcliente;
    private javax.swing.JTextField JT_rentanombre;
    private javax.swing.JTextField JT_rentoclave;
    private javax.swing.JTextField JT_setidcliente;
    private javax.swing.JTextField JT_setidrenta;
    private javax.swing.JTable JT_tablaclientes;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private java.awt.Label label1;
    private java.awt.Label label2;
    // End of variables declaration//GEN-END:variables

}
